<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    /* 
    ES6 引入了一种新的原始数据类型 Symbol ，表示独一无二的值，
    最大的用法是用来定义对象的唯一属性名
    */
    const s1 = Symbol('name')
    const s2 = Symbol('name')
    console.log(s1, s2, s1==s2) // false
    console.log(typeof s1) // 'symbol'

    const obj = {}
    obj[s1] = 'atguigu'
    obj[s2] = 'abc'
    console.log(obj[s1], obj[s2]) //  atguigu abc

    console.log(Object.keys(obj))
    Object.getOwnPropertySymbols(obj).forEach(key=> {
      console.log(key, obj[key])
    })

    /* 
    MDN文档: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Symbol
    */
  </script>
</body>
</html>